using System;
using Science.Mathematics;
using M = Science.Mathematics.Calculus;
using L=Science.Physics.GeneralPhysics;

namespace Serway.Chapter30
{
	/// <summary>
	/// Example01: Magnetic Field Surrounding a Thin, Straight Conductor
	/// Consider a thin, straight wire carrying a constant 
	/// current I and placed along the x axis as shown in Figure 30.3.
	/// Determine the magnitude and direction of the magnetic field 
	/// at point P due to this current.
	/// </summary>
	public class Example01
	{
		public Example01()
		{
		}
		private string result;
		public string Result
		{
			get{return result;}
		}
		public void Compute()
		{
			L.MagneticField B = new L.MagneticField();
			
			L.Line.Parameterization fa = new L.Line.Parameterization(Line);
			L.Line l = new L.Line(fa);
			l.ParameterStartValue = -1.0;
			l.ParameterEndValue = 2.0;
		
			L.ElectricCurrent I = new L.ElectricCurrent();
			I.A = 10.0;

			L.Position x = new L.Position();
			x.X = 0.0;
			x.Y = 1.0;
			x.Z = 0.0;
			
			B.BiotSavartLaw(I,l,x);

			result+=Convert.ToString(B.X)+"\r\n"
				+Convert.ToString(B.Y)+"\r\n"
				+Convert.ToString(B.Z)+"\r\n";

			result+=Convert.ToString(L.Constant.
				PermeabilityOfFreeSpace*I.A/4.0/Math.PI
				/1.0*(1.0/Math.Sqrt(1.0+1.0)+2.0/Math.Sqrt(1.0+4.0)))+"\r\n";
		}
		private L.Position Line(double t)
		{
			L.Position xyz = new L.Position();
			xyz.X = t;
			xyz.Y = 0.0;
			xyz.Z = 0.0;
			return xyz;
		}
	}
}
